package string;

public class ChatAtDemo {
    public static void main(String[] args) {
        //`         01234567890
        String str="www.tedu.cn";
        char c =str.charAt(5 );
        System.out.println(c);


        for (int i = 0; i < str.length(); i++) {
            System.out.println(str.charAt(i));
        }


        //判断回文
        String line = "上海自来水来自海上";
        /*
            回文的判断标准:对称
         */
       /* int i=0;
        for (;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                break;
            }
        }
        if(i==line.length()/2) {
            System.out.println("是回文");
        }*/


        //第二种思路
       /* boolean match = true;//默认匹配为"是回文"
        for (int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                match = false;
                break;
            }
        }
        if(match) {
            System.out.println("是回文");
        }*/

        //第三种思路
       /* for (int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                return;
            }
        }
        System.out.println("是回文");*/


        for (int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.print("不");
                break;
            }
        }
        System.out.println("是回文");

    }
}
